var generateMatrix = function(n) {
    let startx = 0,starty = 0;
    let offset = 1;
    let count = 1;
    let loop = n/2;
    let i,j;
    let nums = new Array(n).fill(0).map(() => new Array(n).fill(0));
    let mid = Math.floor(n/2);
    while(loop--) {
        for(j = 0;j < n - offset;j++) {
            nums[startx][j] = count++
        }
        for(i = 0;i < n-offset;i++) {
            nums[i][j] = count++;
        }
         for(;j>starty;j--) {
            nums[i][j] = count++;
        }
        for(;i>startx;i--) {
            nums[i][j] = count++;
        }
       
        startx++;
        starty++;
        offset++;
    }
    if(n%2==1) {
        nums[mid][mid] = count;
    }
    return nums;
 };


let arr =  generateMatrix(1);
console.log(arr,"--arr");